package com.example.shiwuyouproject.utils

import android.app.Activity
import android.content.Context
import android.widget.ImageView
import com.bumptech.glide.Glide
import com.bumptech.glide.request.RequestOptions
import com.example.shiwuyouproject.R
import com.example.shiwuyouproject.net.http.Api
import com.example.shiwuyouproject.ui.pup.AlbumPopupView
import com.luck.picture.lib.PictureSelector
import com.luck.picture.lib.config.PictureConfig
import com.luck.picture.lib.config.PictureMimeType
import com.lxj.xpopup.XPopup

object GlideUtils {

    var headerOption = RequestOptions()

    //        .error(R.mipmap.ic_heard)
    fun headPortrait(context: Context, imView: ImageView, url: String) {
        var myUrl = ""
        if (url.contains("http")) {
            myUrl = url
        } else {
            myUrl = Api.IMAGEHEAD + url
        }
        Glide.with(context)
            .applyDefaultRequestOptions(headerOption)
            .load(myUrl)
            .into(imView)
    }

    var fangImgOption = RequestOptions()

    fun fangImgPortrait(context: Context, imView: ImageView, url: String) {
        fangImgOption.error(R.mipmap.icon_cuowu)
        fangImgOption.placeholder(R.mipmap.icon_cuowu)
        var myUrl = ""
        myUrl = if (url.contains("http")) {
            url
        } else {
            Api.IMAGEHEAD + url
        }
        myUrl=myUrl.replace(" ","")
        Glide.with(context)
            .applyDefaultRequestOptions(fangImgOption)
            .load(myUrl)
            .into(imView)
    }


}